package zjh_20230329;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;

public class Demo02 {
    public static void main(String[] args){
        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream("D:\\kaifamiao\\ioFile.txt");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }


        try {
            int read = fileInputStream.read();
            System.out.println(read);
            System.out.println((char) read);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        //读取字节数
        try {
            int available = fileInputStream.available();
            System.out.println(available);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


        try {
            fileInputStream.skip(10);
            int read1 = fileInputStream.read();
            System.out.println((char) read1);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


        byte[] bytes = new byte[10];
        try {
            int read = fileInputStream.read(bytes);
            System.out.println(read);
            System.out.println( Arrays.toString( bytes));
            System.out.println(new String(bytes));
            byte[] bytes1 = fileInputStream.readAllBytes();
            System.out.println(Arrays.toString(bytes1));
            System.out.println(new String(bytes1));
            fileInputStream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
